using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Comteck.Winforms.Forms;
using Comteck.Timing;

namespace Comteck.Winforms.Dialog {
  public partial class FrmDateTimeDialog : FrmDialogBase {
    [Browsable(false)]
    public Action<DateTime> ImportAction { get; set; }

    public DateTime DateTime { get; set; } = Clock.Now;

    public FrmDateTimeDialog() {
      InitializeComponent();
    }

    private void FrmDateTimeDialog_Load(object sender, EventArgs e) {
      // 默认自动延时一天
      this.dtDateTime.DateTime = this.DateTime.AddDays(1.0);
    }

    private void btnConfirm_Click(object sender, EventArgs e) {
      this.DateTime = this.dtDateTime.DateTime;

      this.ImportAction?.Invoke(this.DateTime);

      this.DialogResult = DialogResult.OK;
    }

    private void btnClose_Click(object sender, EventArgs e) {
      this.Close();
    }
  }
}
